#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
using namespace std;
struct people
{
    int flag;
    int id, vir, tal, tol;
};
bool cmp(people p1, people p2)
{
    if (p1.flag != p2.flag)
        return p1.flag > p2.flag;
    else if (p1.tol != p2.tol)
        return p1.tol > p2.tol;
    else if (p1.vir != p2.vir)
        return p1.vir > p2.vir;
    else if(p1.id != p2.id)
        return p1.id < p2.id;
    else
        return false;
}
int main()
{
    people p;
    vector<people> peoples;
    int n, l, h;
    scanf("%d %d %d", &n, &l, &h);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d %d", &p.id, &p.vir, &p.tal);
        p.tol = p.vir + p.tal;
        p.flag = 1;
        if (p.vir >= h && p.tal >= h)
            p.flag = 4;
        if (p.vir >= h && p.tal < h && p.tal >= l)
            p.flag = 3;
        if (p.vir < h && p.tal < h && p.vir >= l && p.tal >= l && p.vir >= p.tal)
            p.flag = 2;
        if (p.vir >= l && p.tal >= l)
            peoples.push_back(p);
    }
    sort(peoples.begin(), peoples.end(), cmp);
    printf("%d\n", peoples.size());
    for (int i = 0; i < peoples.size(); i++)
    {
        printf("%d %d %d\n", peoples[i].id, peoples[i].vir, peoples[i].tal);
    }
}